#!/usr/bin/env bash
#########################################################################
# File Name   : nova.sh.j2
# Author      : seadog
# mail        : seadog0514@163.com
# Version     : 0.1
# Created Time: Mon 2024-09-30 13:17:38(+0800)
#########################################################################

#
#
# Usage:

{
  set -euo pipefail
}

source /root/keystonerc

openstack user create --domain default --project service --password {{ service_password }} cinder

# add [cinder] user in [admin] role
openstack role add --project service --user cinder admin
# add [cinder] user in [service] role
openstack role add --project service --user cinder service
# add [nova] user in [service] role
openstack role add --project service --user nova service
# create service entry for [cinder]
openstack service create --name cinderv3 --description "OpenStack Block Storage" volumev3

# define Cinder API Host
export controller={{ openstack_master_ip }}
# create endpoint for [cinder] (public)
openstack endpoint create --region RegionOne volumev3 public https://$controller:8776/v3/%\(tenant_id\)s

# create endpoint for [cinder] (internal)
openstack endpoint create --region RegionOne volumev3 internal https://$controller:8776/v3/%\(tenant_id\)s

# create endpoint for [cinder] (admin)
openstack endpoint create --region RegionOne volumev3 admin https://$controller:8776/v3/%\(tenant_id\)s
